{% macro articles(_articles) %}
    {% for item in _articles %}
        <li class="chapter {% if item.path == _input %}active{% endif %}" data-level="{{ item.level }}" {% if item.path and not item.external %}data-path="{{ item.path|contentLink }}"{% endif %}>
            {% if item.path and item.exists %}
                {% if not item.external %}
                    <a href="{{ basePath }}/{{ item.path|contentLink }}">
                {% else %}
                    <a target="_blank" href="{{ item.path }}">
                {% endif %}
                        <i class="fa fa-check"></i>
                        {% if item.level != "0" %}
                            <b>{{ item.level }}.</b>
                        {% endif %}
                        {{ item.title }}
                    </a>
            {% else %}
            <span><b>{{ item.level }}.</b> {{ item.title }}</span>
            {% endif %}
            {% if item.articles.length > 0 %}
            <ul class="articles">
                {{ articles(item.articles) }}
            </ul>
            {% endif %}
        </li>
    {% endfor %}
{% endmacro %}

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            {% set _divider = false %}
            {% if options.links.sidebar %}
            {% for linkTitle, link in options.links.sidebar %}
                {% set _divider = true %}
                <li>
                    <a href="{{ link }}" target="blank" class="custom-link">{{ linkTitle }}</a>
                </li>
            {% endfor %}
            {% endif %}

            {% if _divider %}
            <li class="divider"></li>
            {% endif %}

            {{ articles(summary.chapters) }}

            {% if options.links.gitbook != false %}
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    {{ __("GITBOOK_LINK") }}
                </a>
            </li>
            {% endif %}
        </ul>
    </nav>
</div>
